
<!DOCTYPE html>
<html lang="zh" class="loading">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>JAVASE _1 - 二月の档案室</title>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="google" content="notranslate" />
    <meta name="keywords" content="二月,"> 
    <meta name="description" content="所感所想，所言所行，我将以文字记录我自己。,C语言贴近硬件，运行快，效率高操作系统，编译器，数据库，网络系统  【非常严格】指针和内存管理
1982 C++	【非常复杂的特性】【需要非常多的底层知识】面向对象兼容C图形领域，游戏
JAVA语法,"> 
    <meta name="author" content="Allureluoli"> 
    <link rel="alternative" href="atom.xml" title="二月の档案室" type="application/atom+xml"> 
    <link rel="icon" href="/img/favicon.png"> 
    
    
    
    <meta name="twitter:card" content="summary"/>
    <meta name="twitter:title" content="JAVASE _1 - 二月の档案室"/>
    <meta name="twitter:description" content="所感所想，所言所行，我将以文字记录我自己。,C语言贴近硬件，运行快，效率高操作系统，编译器，数据库，网络系统  【非常严格】指针和内存管理
1982 C++	【非常复杂的特性】【需要非常多的底层知识】面向对象兼容C图形领域，游戏
JAVA语法,"/>
    
    
    
    
    <meta property="og:site_name" content="二月の档案室"/>
    <meta property="og:type" content="object"/>
    <meta property="og:title" content="JAVASE _1 - 二月の档案室"/>
    <meta property="og:description" content="所感所想，所言所行，我将以文字记录我自己。,C语言贴近硬件，运行快，效率高操作系统，编译器，数据库，网络系统  【非常严格】指针和内存管理
1982 C++	【非常复杂的特性】【需要非常多的底层知识】面向对象兼容C图形领域，游戏
JAVA语法,"/>
    
<link rel="stylesheet" href="/css/diaspora.css">

    <script>window.searchDbPath = "/search.xml";</script>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro&display=swap" rel="stylesheet">
<meta name="generator" content="Hexo 6.3.0"></head>

<body class="loading">
    <span id="config-title" style="display:none">二月の档案室</span>
    <div id="loader"></div>
    <div id="single">
    <div id="top" style="display: block;">
    <div class="bar" style="width: 0;"></div>
    <a class="iconfont icon-home image-icon" href="javascript:;" data-url="http://example.com"></a>
    <div title="播放/暂停" class="iconfont icon-play"></div>
    <h3 class="subtitle">JAVASE _1</h3>
    <div class="social">
        <div>
            <div class="share">
                <a title="获取二维码" class="iconfont icon-scan" href="javascript:;"></a>
            </div>
            <div id="qr"></div>
        </div>
    </div>
    <div class="scrollbar"></div>
</div>

    <div class="section">
        <div class="article">
    <div class='main'>
        <h1 class="title">JAVASE _1</h1>
        <div class="stuff">
            <span>七月 20, 2022</span>
            
  <ul class="post-tags-list" itemprop="keywords"><li class="post-tags-list-item"><a class="post-tags-list-link" href="/tags/JAVA/" rel="tag">JAVA</a></li><li class="post-tags-list-item"><a class="post-tags-list-link" href="/tags/%E5%9F%BA%E7%A1%80/" rel="tag">基础</a></li></ul>


        </div>
        <div class="content markdown">
            <p>C语言<br>贴近硬件，运行快，效率高<br>操作系统，编译器，数据库，网络系统  【非常严格】<br>指针和内存管理</p>
<p>1982 C++	【非常复杂的特性】【需要非常多的底层知识】<br>面向对象<br>兼容C<br>图形领域，游戏</p>
<p>JAVA<br>语法像C<br>没有指针<br>没有内存管理<br>真正的可移植性，到处运行（）<br>面向对象<br>类型安全<br>高质量类库<br>层叫 	C++ –</p>
<p>JAVA初生</p>
<p>图形界面程序 Applet</p>
<p>Java 2 桌面 J2SE</p>
<p>Java 2移动版 J2ME 占领手机</p>
<p>Java 2服务器 J2EE</p>
<hr>
<p>构建工具：Ant,Mavern,Jekins</p>
<p>应用服务器：Tomcat,Jetty,Jboss,Websphere,weblogic</p>
<p>Web开发：Struts,Spring,Hibernate,myBatis</p>
<p>开发工具：Eclipse,Netbean,intellij ideam,JbUILDER</p>
<p>2006： Hadoop</p>
<p>2008:	Android</p>
<hr>
<p>JAVA特性和优势</p>
<p>简单性</p>
<p>面向对象</p>
<p>可移植性</p>
<p>高性能</p>
<p>分布式</p>
<p>动态性	反射机制</p>
<p>多线程</p>
<p>安全性</p>
<p>健壮性	通过捕获异常来解决异常</p>
<p>【心态】：去学习的过程中爱上它，这样才能主动学习</p>
<p>JAVA的成功：实力 + 运气 找到了互联网发展的节奏</p>
<hr>
<p>JAVA三大版本</p>
<p>Write Once \Run Anywhere （虚拟机）</p>
<p>JavaSE：标准版 （桌面程序，控制台开发）</p>
<p>JavaME: 嵌入式开发 （手机，小家电） 【冷门】</p>
<p>JavaEE: E企业级开发 （web端，服务器开发）</p>
<hr>
<p>JDK包含 JRE 全称：Java Development Kit [工具]</p>
<p>JRE 全称 ： Java Runtime Environment [运行]</p>
<p>JVM: 全称 JAVA Virtual Machine [虚拟机]</p>
<p>通过虚拟机屏蔽了底层数据的差别</p>
<p>JAVA SE API 【接口】</p>
<hr>
<p>JAVA开发环境搭建</p>
<ul>
<li>JDK下载与安装</li>
<li>JDK 卸载 ：</li>
</ul>
<p>​	1.删除JAVA安装目录</p>
<p>​	2.删除变量 （电脑属性，环境变量，path）</p>
<p>​	3.java -version</p>
<ul>
<li><p>安装JAVA</p>
<ol>
<li><p>搞到安装包</p>
</li>
<li><p>设置JAVA_HOME</p>
</li>
<li><p>设置path变量</p>
</li>
<li><p>(%表示引用)</p>
</li>
</ol>
</li>
<li><p>测试 java -version</p>
</li>
<li><p>src.zip 中有java源码</p>
</li>
<li><p>lib为库</p>
</li>
<li><p>include为C的头文件目录</p>
</li>
</ul>
<hr>
<p>我的JAVA对世界的第一声呐喊</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"> java <span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Hello</span> &#123;  <span class="comment">//类名</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[]args)</span>&#123;  <span class="comment">//方法</span></span><br><span class="line">		System.out.print(<span class="string">&quot;Hello,World!&quot;</span>);</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>源码如上</p>
<hr>
<p>承接上文	在搞完了之后爷就遇到了+编码问题</p>
<p>所幸在之前的RWmod开发中早已经遇到过类似的，便直接上网求证，很快解决了。</p>
<p>原因为txt的UFT-8中是带ROM的，而 javac是无法识别带ROM 的UFT-8</p>
<p>只好安装了一个Notepad++，将编码修改后，便可以正常运行了。</p>
<p>唔，以后池沼开发一个自己的编译器，这个用着真不舒服。。</p>
<hr>
<p>解决问题的网址</p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/White_Idiot/article/details/54670243">https://blog.csdn.net/White_Idiot/article/details/54670243</a></p>
<p>同时学到了一条新命令</p>
<p>javac -encoding “UTF-8” FirstSample.java</p>
<p>通过指定编码的方式运行javac</p>
<hr>
<p>注意事项</p>
<ul>
<li>大小写问题</li>
<li>中英文问题</li>
</ul>
<hr>
<p>使用IDEA开发环境</p>
<p>新建方法 -新建类 - 快捷键 (待补充)</p>
<hr>
<p>JAVA基本语法</p>
<ol>
<li>注释、标识符</li>
<li>数据类型</li>
<li>类型转换</li>
<li>变量、常量</li>
<li>运算符</li>
<li>包机制、JavaDoc</li>
</ol>
<hr>
<p>IDEA的项目设置五大类</p>
<ul>
<li><p>Project 项目</p>
<p>|name   |   SDK   |  Language level |  Compiler output ps:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">名称	  |   工具   |   语言等级 		  |   输出文件夹       </span><br></pre></td></tr></table></figure></li>
</ul>
<p>​    输出文件夹 ps: Used  for modules subdirectories, Production and Test directories for the corresponding sources.</p>
<p>​	翻译：用于相应源的模块子目录、生产目录和测试目录。</p>
<ul>
<li><p>Modules 模块</p>
<p>Name: 模块的名称														Add Content Root（添加新的内容根）</p>
<p>Sources   |  Paths   |   Dependencies</p>
<p>源			  |   路径     |  依赖关系</p>
</li>
</ul>
<p>Sources ： Language level </p>
<p>文件夹标记</p>
<p>Mark as:   Sources \blue\    Tests \green\  Resources\资源\   Test Resources\测试资源\  Excluded\排除\</p>
<p>Paths : Compiler Output （编译器输出）：Inherit project compile output path(和项目输出路径相同)</p>
<p>​																		：Use module compile output path （使用模块编译输出路径）</p>
<p>JavaDoc：Manage external JavaDocs attached to this module, External JavaDoc override Javadoc override Java DOc annotations you might have in your module.（管理附加到此模块的外部JavaDoc，外部JavaDoc覆盖模块中可能有的JavaDoc注释。）</p>
<ul>
<li>Libraries 图书馆</li>
</ul>
<p>​	   Nothing to show（没啥可展示的）	</p>
<p>​	   右侧  Select a library to view or edit its details here (在此处选择要查看或编辑其详细信息的库)</p>
<ul>
<li><p>Facets  面</p>
<p>No facets are configured(没有配置的面)</p>
<p>Detection (检查)</p>
<p>右侧 ：Enable framework detection（启用检测框架）</p>
<p>​			 Exclude from detection(排除在检测外) </p>
</li>
<li><p>Artifacts</p>
</li>
</ul>
<p>  即编译后的Java类，Web资源等的整合，用以测试、部署等工作。再白话一点，就是说某个module要如何打包，例如war exploded、war、jar、ear等等这种打包形式。某个module有了 Artifacts 就可以部署到应用服务器中了。</p>
<h3 id="注释"><a href="#注释" class="headerlink" title="注释"></a>注释</h3><p>&#x2F;&#x2F; 单行注释</p>
<p>&#x2F;*   *&#x2F; 多行注释</p>
<hr>
<h3 id="关键字"><a href="#关键字" class="headerlink" title="关键字"></a>关键字</h3><table>
<thead>
<tr>
<th align="center">abstract</th>
<th>assert</th>
<th>bollean</th>
<th>break</th>
<th>byte</th>
</tr>
</thead>
<tbody><tr>
<td align="center">case</td>
<td>catch</td>
<td>char</td>
<td>calss</td>
<td>conse</td>
</tr>
<tr>
<td align="center">continue</td>
<td>default</td>
<td>do</td>
<td>double</td>
<td>else</td>
</tr>
<tr>
<td align="center">enum</td>
<td>extends</td>
<td>final</td>
<td>finally</td>
<td>float</td>
</tr>
<tr>
<td align="center">for</td>
<td>goto</td>
<td>if</td>
<td>implements</td>
<td>import</td>
</tr>
<tr>
<td align="center">instanceof</td>
<td>int</td>
<td>interface</td>
<td>long</td>
<td>native</td>
</tr>
<tr>
<td align="center">new</td>
<td>package</td>
<td>private</td>
<td>protected</td>
<td>public</td>
</tr>
<tr>
<td align="center">return</td>
<td>strictfp</td>
<td>short</td>
<td>static</td>
<td>super</td>
</tr>
<tr>
<td align="center">switch</td>
<td>synchronized</td>
<td>this</td>
<td>throw</td>
<td>throws</td>
</tr>
<tr>
<td align="center">transient</td>
<td>try</td>
<td>void</td>
<td>volatile</td>
<td>while</td>
</tr>
</tbody></table>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">calss1</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="type">String</span> <span class="variable">qwq</span> <span class="operator">=</span><span class="string">&quot;233&quot;</span>; <span class="comment">//qwq为标识符，以小写字母开头</span></span><br><span class="line">        <span class="type">String</span> <span class="variable">QAQ</span> <span class="operator">=</span> <span class="string">&quot;233&quot;</span>;<span class="comment">//大写字母</span></span><br><span class="line">        <span class="type">String</span> <span class="variable">$qwq</span> <span class="operator">=</span> <span class="string">&quot;233&quot;</span>;<span class="comment">//美元符号</span></span><br><span class="line">        <span class="type">String</span> <span class="variable">_QWQ</span> <span class="operator">=</span> <span class="string">&quot;233&quot;</span>;<span class="comment">//下划线</span></span><br><span class="line">        String 傻逼 = <span class="string">&quot;233&quot;</span>;<span class="comment">//中文命名</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//标识符是大小写敏感得</span></span><br></pre></td></tr></table></figure>

<h2 id="JAVA-数据类型"><a href="#JAVA-数据类型" class="headerlink" title="JAVA 数据类型"></a>JAVA 数据类型</h2><h3 id="JAVA为强类型语言"><a href="#JAVA为强类型语言" class="headerlink" title="JAVA为强类型语言"></a>JAVA为强类型语言</h3><ul>
<li><p>要求变量的使用严格符合规定，所有变量必须先定义后使用</p>
<p>弱类型就反之了（例：VB，JS ）</p>
</li>
</ul>
<h4 id="JAVA的数据类型分为两大类"><a href="#JAVA的数据类型分为两大类" class="headerlink" title="JAVA的数据类型分为两大类"></a>JAVA的数据类型分为两大类</h4><ul>
<li><p>基本类型 primitive type</p>
<ol>
<li>整数类型: byte1个字节范围 short 2个字节范围 int 四个字节范围 long 8个字节范围</li>
<li>浮点类型 ： float 占四个字符范围 double 占8个字符范围</li>
<li>字符类型： char 占两个字节</li>
<li>boolean类型：占1位，只有true 和 false</li>
</ol>
</li>
<li><p>引用类型 reference type ：类、接口、数组</p>
</li>
</ul>
<hr>
<p>变量需要初始化 &#x3D; 变量需要定义</p>
<p>int 和 String 都是类型</p>
<p>int 整数  String 字符串</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.sql.SQLOutput;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">calss2</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="comment">// 整数扩展： 进制 二进制 八进制 十六进制</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">10</span>; <span class="comment">//</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">i2</span> <span class="operator">=</span> <span class="number">010</span>; <span class="comment">// 八进制</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">i3</span> <span class="operator">=</span> <span class="number">0x10</span>; <span class="comment">//十六进制 0x开头</span></span><br><span class="line"></span><br><span class="line">        System.out.println(i);</span><br><span class="line">        System.out.println(i2);</span><br><span class="line">        System.out.println(i3);</span><br><span class="line">        System.out.println(<span class="string">&quot;-------------------------------------------&quot;</span>);</span><br><span class="line">        <span class="comment">//-------------------------------------------</span></span><br><span class="line">        <span class="comment">//浮点数扩展： 有限 离散 舍入误差 大约 接近但不等于</span></span><br><span class="line">        <span class="comment">//最好减少使用浮点数进行表示和比较 ，由于浮点数字长有限所以有误差得</span></span><br><span class="line">        <span class="comment">//float（浮点数）</span></span><br><span class="line">        <span class="type">float</span> <span class="variable">f</span> <span class="operator">=</span><span class="number">0.1f</span>; <span class="comment">//0.1</span></span><br><span class="line">        <span class="type">double</span> d= <span class="number">1.0</span>/<span class="number">10</span>; <span class="comment">//0.1</span></span><br><span class="line">        System.out.println(f==d);</span><br><span class="line">        <span class="comment">//字符扩展</span></span><br><span class="line">        <span class="type">char</span> <span class="variable">c1</span> <span class="operator">=</span><span class="string">&#x27;a&#x27;</span>;</span><br><span class="line">        <span class="type">char</span> <span class="variable">c2</span> <span class="operator">=</span><span class="string">&#x27;中&#x27;</span>;</span><br><span class="line">        System.out.println(c1);</span><br><span class="line">        System.out.println((<span class="type">int</span>)c1);<span class="comment">//强制换行</span></span><br><span class="line">        System.out.println(c2);</span><br><span class="line">        System.out.println((<span class="type">int</span>)c2);<span class="comment">//强制换行</span></span><br><span class="line">        <span class="comment">//所有字符本质还是数字</span></span><br><span class="line">        <span class="comment">//编码 Unicode 表：97 = a 2字节 65 =A</span></span><br><span class="line">        <span class="comment">// U0000 UFFFF 为Unicode编码格式</span></span><br><span class="line">        <span class="type">char</span> <span class="variable">c3</span> <span class="operator">=</span><span class="string">&#x27;\u0061&#x27;</span>;  <span class="comment">//一个Unicode字符进行转换</span></span><br><span class="line">        System.out.println(c3);</span><br><span class="line">        <span class="comment">//转义字符 \t 制表符</span></span><br><span class="line">        <span class="comment">// \n 换行</span></span><br><span class="line">        <span class="comment">// 更多转义字符待查</span></span><br><span class="line">        System.out.println(<span class="string">&quot;-------------------------------------------&quot;</span>);</span><br><span class="line">        <span class="type">String</span> <span class="variable">sa</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">String</span>(<span class="string">&quot;Hello&quot;</span>);</span><br><span class="line">        <span class="type">String</span> <span class="variable">sb</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">String</span>(<span class="string">&quot;Hello&quot;</span>);</span><br><span class="line">        System.out.println(sa==sb);<span class="comment">//判断相等 “==” //判断为不相等</span></span><br><span class="line"></span><br><span class="line">        <span class="type">String</span> <span class="variable">sc</span> <span class="operator">=</span> <span class="string">&quot;Hello&quot;</span>;</span><br><span class="line">        <span class="type">String</span> <span class="variable">sd</span> <span class="operator">=</span> <span class="string">&quot;Hello&quot;</span>;</span><br><span class="line">        System.out.println(sc==sd); <span class="comment">//识别为相等</span></span><br><span class="line">        <span class="comment">//对象</span></span><br><span class="line">        <span class="comment">//布尔值扩展</span></span><br><span class="line">        <span class="type">boolean</span> <span class="variable">flag</span> <span class="operator">=</span> <span class="literal">true</span>;</span><br><span class="line">        <span class="keyword">if</span> (flag==<span class="literal">true</span>) &#123;&#125;</span><br><span class="line">        <span class="keyword">if</span> (flag)&#123;&#125;   <span class="comment">//默认是等于true</span></span><br><span class="line">        &#125; <span class="comment">//Less is more! 代码精简易读</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<hr>
<h4 id="字节"><a href="#字节" class="headerlink" title="字节"></a>字节</h4><p>位（bit）</p>
<p>字节（byte）</p>
<p>1B &#x3D; 8BIT</p>
<p>字母：指的是计算机中的字母、数字、字和符号。</p>
<p>电脑32位和64位的区别，寻指的能力，可以装的内存不同，</p>
<hr>
<h3 id="类型转换"><a href="#类型转换" class="headerlink" title="类型转换"></a>类型转换</h3><ul>
<li><p>由于JAVA是强类型语言。所以进行有些运算的时候，需要用到类型转换。</p>
<p>低 ——————————————&gt;高</p>
<p>byte , short ,char -&gt; int -&gt; long -&gt; float -&gt; double</p>
<ul>
<li>运算中，不同类型的数据先转换为同一类型，然后进行运算。</li>
</ul>
</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">calss3</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span><span class="number">128</span>;</span><br><span class="line">        <span class="type">byte</span> <span class="variable">b</span> <span class="operator">=</span> (<span class="type">byte</span>)i;<span class="comment">//强制转换 byet最大值为127 ，所以内存溢出了。输出值变成了-128 //高--&gt;低</span></span><br><span class="line">        <span class="comment">//自动转换  低--高</span></span><br><span class="line">        System.out.println(b);</span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">        1.不能对布尔值进行转换</span></span><br><span class="line"><span class="comment">        2.不能把对象类型转换为不相干的类型</span></span><br><span class="line"><span class="comment">        3.在把大容量转换为低容量的时候，强制转换</span></span><br><span class="line"><span class="comment">        4.转换的时候可能存在内存溢出</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        System.out.println(<span class="string">&quot;---------------------&quot;</span>);</span><br><span class="line">        System.out.println((<span class="type">int</span>)<span class="number">23.7</span>); <span class="comment">//23 会导致精度问题</span></span><br><span class="line">        System.out.println((<span class="type">int</span>)-<span class="number">45.89f</span>); <span class="comment">//-45</span></span><br><span class="line">        <span class="type">char</span> <span class="variable">c</span> <span class="operator">=</span><span class="string">&#x27;a&#x27;</span>;</span><br><span class="line">        <span class="type">int</span> <span class="variable">d</span> <span class="operator">=</span> c+<span class="number">1</span>;<span class="comment">//转换成了int形式，低向高自动转换</span></span><br><span class="line">        System.out.println(d);</span><br><span class="line">        System.out.println((<span class="type">char</span>)d);<span class="comment">//强制转换为字符，输出为b</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">class4</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="comment">//操作比较大的数的时候，注意溢出问题</span></span><br><span class="line">        <span class="comment">//JDK7新特性，数字直接可以用下划线分割</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">money</span> <span class="operator">=</span> <span class="number">10_0000_000</span>;</span><br><span class="line">        <span class="type">int</span> <span class="variable">years</span> <span class="operator">=</span> <span class="number">20</span>;</span><br><span class="line">        <span class="type">int</span> <span class="variable">total</span> <span class="operator">=</span> money*years; <span class="comment">// 输出后返回的为数字，计算的时候溢出了</span></span><br><span class="line">        <span class="type">long</span> <span class="variable">total2</span> <span class="operator">=</span> money*years;<span class="comment">//默认为Int，转换之前已经存在问题了，所以无用</span></span><br><span class="line">        <span class="type">long</span> <span class="variable">total3</span> <span class="operator">=</span> money*((<span class="type">long</span>)years);<span class="comment">//先把一个数转换为long，则整个表达式提升，全部用Long计算，则不会内存溢出，就没事了。</span></span><br><span class="line">        System.out.println(tota3);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="变量"><a href="#变量" class="headerlink" title="变量"></a>变量</h3><p>变量定义：可以把变化的量。</p>
<p>JAVA是一种强类型语言，每个变量都必须声明其类型。</p>
<p>JAVA变量是程序中最基本的存储单元，其要素包括变量名变量类型和作用域。</p>
<p>变量划分内存的空间</p>
<ul>
<li><p>作用域：</p>
<ul>
<li>类变量</li>
<li>实例变量</li>
</ul>
</li>
<li><p>局部变量</p>
</li>
</ul>
<hr>
<ul>
<li><p>格式 </p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">  type varname	[=value] [&#123;,varName[=value]];</span><br><span class="line">  <span class="comment">//数据类型  变量名 =值；可以用逗号隔开来声明多个同类型变量。</span></span><br><span class="line">                             <span class="comment">//ps：老师不建议在一行里定义多个值，会看起来比较复杂。 </span></span><br><span class="line"></span><br><span class="line">```java</span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">class5</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="comment">//int a,b,c; //定义a b c 为int类型</span></span><br><span class="line">       <span class="comment">//int a=1,b=2,c=3; //定义a,b,c三个的量，但是程序可读性不好</span></span><br><span class="line">        <span class="type">int</span> a=<span class="number">1</span>;</span><br><span class="line">        <span class="type">int</span> b=<span class="number">2</span>;</span><br><span class="line">        <span class="type">int</span> c=<span class="number">3</span>; <span class="comment">//单独定义可读性会好</span></span><br><span class="line">        <span class="type">String</span> <span class="variable">name</span> <span class="operator">=</span><span class="string">&quot;23333&quot;</span>; <span class="comment">//定义一个name为字符串</span></span><br><span class="line">        <span class="type">char</span> <span class="variable">x</span> <span class="operator">=</span> <span class="string">&#x27;X&#x27;</span>; <span class="comment">//定义x为一个字符</span></span><br><span class="line">        <span class="type">double</span> <span class="variable">pi</span> <span class="operator">=</span><span class="number">3.4</span>; <span class="comment">//定义pi为一个数字</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">class08</span> &#123;</span><br><span class="line">    <span class="keyword">static</span> <span class="type">double</span> <span class="variable">salary</span> <span class="operator">=</span> <span class="number">2500</span>;<span class="comment">//加前期变量都加static，这个static定义了一个变量</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">//实例变量：从属于对象，如果不自行初始化，这个类型的默认值则为0 或0.0；所以14行输出了一个0</span></span><br><span class="line">    <span class="comment">//字符串初始化为16位的0000....，布尔值默认为false</span></span><br><span class="line">    <span class="comment">//除了以上的基本类型，其他的初始值都为null</span></span><br><span class="line">    String name; <span class="comment">//变量在类里</span></span><br><span class="line">    <span class="type">int</span> age;</span><br><span class="line">    <span class="comment">//属性：变量</span></span><br><span class="line">    <span class="comment">//main 方法</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line"></span><br><span class="line">        <span class="type">int</span> i=<span class="number">10</span>;<span class="comment">//定义一个i为局部变量，只能在此处使用，且初始化值。</span></span><br><span class="line">        System.out.println();</span><br><span class="line">       <span class="comment">// 变量类型 变量名字 = new class08 ,相当于把自己拿到了。</span></span><br><span class="line">        <span class="type">class08</span> <span class="variable">class08</span> <span class="operator">=</span><span class="keyword">new</span> <span class="title class_">class08</span>();</span><br><span class="line">        System.out.println(class08);<span class="comment">//输出class08@1b6d3586</span></span><br><span class="line">        System.out.println(class08.age);<span class="comment">//输出0</span></span><br><span class="line">        System.out.println(class08.name);<span class="comment">//输出null</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//其他方法</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">add</span><span class="params">()</span>&#123;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>







<ul>
<li>常量 （Constant）:初始化 （initialize）后不能再改变值！不会编队的值。</li>
<li>所谓常量是一种特殊的变量，它的值被设定后，在程序运行过程中不允许被改变。</li>
</ul>
<p>格式：  ps:常量名一般使用大写字符</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">final</span> 变量名 值;</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">class09</span> &#123;</span><br><span class="line">    <span class="comment">//修饰符，不存在先后顺序 指final static double PI ,,等号之前的这些东西(但是谁=谁要定义好了)。</span></span><br><span class="line">    <span class="keyword">final</span> <span class="keyword">static</span> <span class="type">double</span> <span class="variable">PI</span> <span class="operator">=</span> <span class="number">3.14</span>; <span class="comment">//定义了一个静态的常量PI</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="变量的命名规范"><a href="#变量的命名规范" class="headerlink" title="变量的命名规范"></a>变量的命名规范</h3><ul>
<li>所有变量、方法、类名：见名知意。</li>
<li>类成员变量：首字母小写和驼峰原则：monthSalary 除了第一个单词以外，后面的单词首字母大写<ul>
<li>例 lastname lastName</li>
</ul>
</li>
<li>局部变量：首字母小写和驼峰原则</li>
<li>常量：大写字母和下划线：MAX_VALUE</li>
<li>类名：首字母大写和驼峰原则：Man,GoodMan</li>
<li>方法名：首字母小写和驼峰原则：run(),runRun()</li>
</ul>
<h3 id="运算符"><a href="#运算符" class="headerlink" title="运算符"></a>运算符</h3><h4 id="JAVA语言支持如下运算符："><a href="#JAVA语言支持如下运算符：" class="headerlink" title="JAVA语言支持如下运算符："></a>JAVA语言支持如下运算符：</h4><ul>
<li>算数运算符：+,-,*,&#x2F;,%（取余&#x3D;模运算）,++,–</li>
<li>赋值运算符： &#x3D;</li>
<li>关系运算符：&gt;,&lt;,&gt;&#x3D;,&lt;&#x3D;,&#x3D;&#x3D;（相等）,!&#x3D;（不等于），instanceof</li>
<li>逻辑运算符：&amp;&amp;,||,!  （与，或，如果是真则为假，如果是假则为真）</li>
<li>位运算符：&amp;，|,^，~,&gt;&gt;,&lt;&lt;,&gt;&gt;&gt;(了解！！！）</li>
<li>条件运算符？：</li>
<li>扩展赋值运算符：+&#x3D;，-&#x3D;，*&#x3D;，&#x2F;&#x3D;</li>
</ul>
<h2 id="IDEA创建包和MOVE"><a href="#IDEA创建包和MOVE" class="headerlink" title="IDEA创建包和MOVE"></a>IDEA创建包和MOVE</h2><p>点击src 右键 new —&gt; Package</p>
<p>此时弹出一个窗</p>
<p>Move :  项目名</p>
<p>To directory: 路径</p>
<p>Search in comments and strings （在字符串中搜索）</p>
<p>Search for text occurrences （所属出现的文本）  &#x2F;&#x2F;这两位默认勾选暂时不管</p>
<p>Open in editor（在编辑器中打开（也叫开放编辑））       &#x2F;&#x2F;此处勾选即可                       </p>
<pre><code>                                                         Refactor     Preview     Cancel
</code></pre>
<p>一次移动多个文件会出现 Refactoring Preview（重构预览）</p>
<p>点击 Do Refactor 即可 ps:原来这tm是个报错</p>
<hr>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> base2;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">class2</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="type">long</span> a= <span class="number">12312345623156415L</span>;</span><br><span class="line">        <span class="type">int</span> <span class="variable">b</span> <span class="operator">=</span><span class="number">123</span>;</span><br><span class="line">        <span class="type">short</span> <span class="variable">c</span> <span class="operator">=</span> <span class="number">10</span>;</span><br><span class="line">        <span class="type">byte</span> <span class="variable">d</span> <span class="operator">=</span> <span class="number">8</span>;</span><br><span class="line">        System.out.println(a+b+c+d);<span class="comment">//有一个数字类型为long则结果类型也为long，如果没有long则结果都为int，（待求证的理解）默认类型为int类型，加入其他类型后，加什么则跟什么，那么同时加了俩会怎么样呢?</span></span><br><span class="line">      <span class="comment">//  System.out.println((String) (c+d)); //触发报错：incovertible tpyes cannot cast &#x27;int&#x27; to &#x27;java.lang.String&#x27;</span></span><br><span class="line">                                                    <span class="comment">//无法将 int 类型转换为 String类型</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="自增"><a href="#自增" class="headerlink" title="自增"></a>自增</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> base2;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">class4</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="comment">//++ -- 自增，自减  一元运算符</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">a</span> <span class="operator">=</span> <span class="number">3</span>; <span class="comment">//定义a为3</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">b</span> <span class="operator">=</span>a++; <span class="comment">//就是 a给自己加个1 （a+1）</span></span><br><span class="line">        System.out.println(a);<span class="comment">//这个回合自增了一下//输出4 因为此时的a已经加了个1</span></span><br><span class="line">        System.out.println(b); <span class="comment">//输出3  也就是说b的值就是a的值，但b的值不是a++的值，a++仅是为了给a再次赋值，让a加1</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">c</span> <span class="operator">=</span>++a; <span class="comment">//自增后给c赋值 这个才是赋值回合</span></span><br><span class="line">        System.out.println(a);<span class="comment">//这个回合再次自增 输出5，c在原先a++的基础上，再次++a</span></span><br><span class="line">        System.out.println(b);<span class="comment">//输出3</span></span><br><span class="line">        System.out.println(c);<span class="comment">//输出5   ps: ++是自增，b = a++ b=a=3 和a++这个a的自增是没有关系的，只是++刚好在b=a这个赋值的时候</span></span><br><span class="line">        System.out.println(c);<span class="comment">//输出5   ps： 而 c =++a 将++放在了前面，则就是c = 再次自增的a</span></span><br><span class="line">        <span class="comment">//话不多说测试一波</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">f</span> <span class="operator">=</span> ++c; <span class="comment">//那么这个f 按照我的理解，f等于 自增后的c，那么输出应该等于6。测试一波</span></span><br><span class="line">        System.out.println(f); <span class="comment">//输出为6 ，没有问题</span></span><br><span class="line">        <span class="comment">//接着测试一波，g = f ++ ，按照我的理解，g = 6 ,f 在这条语句后变成了7</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">g</span> <span class="operator">=</span> f++;</span><br><span class="line">        System.out.println(g);</span><br><span class="line">        System.out.println(f);<span class="comment">//over 没有问题~~~</span></span><br><span class="line">         <span class="comment">//幂运算 //这些运算可以使用工具【类】来进行操作，java中有很多的类</span></span><br><span class="line">        <span class="type">double</span> <span class="variable">pow</span> <span class="operator">=</span> Math.pow(<span class="number">2</span>,<span class="number">3</span>);<span class="comment">//Math类提供了很多的科学计算和常数捏</span></span><br><span class="line">        System.out.println(pow);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="逻辑"><a href="#逻辑" class="headerlink" title="逻辑"></a>逻辑</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> base2;</span><br><span class="line"><span class="comment">//逻辑运算符</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">class5</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="comment">// 与（and） 或（or） 非（取反）</span></span><br><span class="line">        <span class="type">boolean</span> <span class="variable">a</span> <span class="operator">=</span><span class="literal">true</span>;</span><br><span class="line">        <span class="type">boolean</span> <span class="variable">b</span> <span class="operator">=</span><span class="literal">false</span>;</span><br><span class="line">        System.out.println(<span class="string">&quot;a %% b ：&quot;</span>+(a&amp;&amp;b));<span class="comment">//逻辑与运算：两个变量都为真，结果才为真，因为只有a是真所以输出假</span></span><br><span class="line">        System.out.println(<span class="string">&quot; a || b：&quot;</span>+(a||b));<span class="comment">//逻辑或运算：两个变量有一个为真则结果为真，因为有一个a是真所以结果是真</span></span><br><span class="line">        System.out.println(<span class="string">&quot;!(a &amp;&amp; b：)&quot;</span>+!(a&amp;&amp;b));<span class="comment">//如果是真，则变为家，如果是假则变为真，因为只有a是真，所以应该输出假，但是取反，输出真</span></span><br><span class="line">        <span class="comment">//短路运算</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">c</span> <span class="operator">=</span> <span class="number">5</span>;</span><br><span class="line">        <span class="type">boolean</span> <span class="variable">d</span> <span class="operator">=</span> (c&lt;<span class="number">4</span>)&amp;&amp;(c++&lt;<span class="number">4</span>);</span><br><span class="line">        System.out.println(d);<span class="comment">//这里输出了假，由于短路运算，在检测到假后后面的就不去考虑了，所以c++并没有运行，c的值还是4</span></span><br><span class="line">        System.out.println(c);<span class="comment">//这里c仍然是5</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">//字符串的连接</span></span><br><span class="line">        System.out.println(<span class="string">&quot;23333&quot;</span>+<span class="string">&quot;woc666&quot;</span>);<span class="comment">//字符串在输出中可以用加号连接捏</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="位运算符"><a href="#位运算符" class="headerlink" title="位运算符"></a>位运算符</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> base2;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">class6</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">        A = 0011 1100</span></span><br><span class="line"><span class="comment">        B = 0000 1101</span></span><br><span class="line"><span class="comment">        A&amp;B = 0000 1100 //两个都是1 才能得1（和相乘差不多）</span></span><br><span class="line"><span class="comment">        A|B = 0011 1101 //只要一个为1，则就是1 1|0=1酱紫得</span></span><br><span class="line"><span class="comment">        A^B = 0011 0001 //两个位置，相同则为0，否则则为1</span></span><br><span class="line"><span class="comment">        ~B  = 1111 0010 //取反，就是反过来啦~</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">        面试题：2*8 怎么运算最快？</span></span><br><span class="line"><span class="comment">        拆分到 2*2*2*2 正常运算需要电路，这个只需要增量（hhh记下来）</span></span><br><span class="line"><span class="comment">        &lt;&lt; 左移  相当于乘2</span></span><br><span class="line"><span class="comment">        &gt;&gt; 右移  相当于除2  （算法中效率贼高~~~）</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">        0000 0000 0</span></span><br><span class="line"><span class="comment">        0000 0001 1</span></span><br><span class="line"><span class="comment">        0000 0010 2</span></span><br><span class="line"><span class="comment">        0000 0011 3</span></span><br><span class="line"><span class="comment">        0000 0100 4</span></span><br><span class="line"><span class="comment">        0000 1000 8</span></span><br><span class="line"><span class="comment">        0001 0000 16</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="扩展运算符（偷懒计算-bushi-）"><a href="#扩展运算符（偷懒计算-bushi-）" class="headerlink" title="扩展运算符（偷懒计算(bushi)）"></a>扩展运算符（偷懒计算(bushi)）</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> base2;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">class7</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="type">int</span> <span class="variable">a</span> <span class="operator">=</span> <span class="number">10</span>;</span><br><span class="line">        <span class="type">int</span> <span class="variable">b</span> <span class="operator">=</span> <span class="number">10</span>;</span><br><span class="line">        a+=b; <span class="comment">//a+=的意思就是a= a+b</span></span><br><span class="line">        a-=b; <span class="comment">// 意思为a = a-b</span></span><br><span class="line">        <span class="comment">//字符串连接</span></span><br><span class="line">        System.out.println(<span class="string">&quot;&quot;</span>+a+b);<span class="comment">//如果字符串连接符出现了前面，则后面所有的都会转换为String类型</span></span><br><span class="line">        System.out.println(a+b+<span class="string">&quot;&quot;</span>);<span class="comment">//正常运算，因为字符串连接符在后面</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="三元运算符"><a href="#三元运算符" class="headerlink" title="三元运算符"></a>三元运算符</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> base2;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">class8</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="comment">// x ? y : z</span></span><br><span class="line">        <span class="comment">// 意思为 如果 x==true,则结果为y,否则结果为z</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">score</span> <span class="operator">=</span><span class="number">80</span>;</span><br><span class="line">        <span class="type">String</span> <span class="variable">type</span> <span class="operator">=</span> score &lt;<span class="number">60</span> ? <span class="string">&quot;不及格&quot;</span>:<span class="string">&quot;及格&quot;</span>;</span><br><span class="line">        System.out.println(type);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>ps :为了方便代码的使用和理解多打括号（）</p>
<h2 id="包机制"><a href="#包机制" class="headerlink" title="包机制"></a>包机制</h2><ul>
<li>为了更好的组织类，JAVA提供了包机制，用于区别类名的命名空间。</li>
<li>包语句的语法格式为：</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> pkg1[. pkg2[. pkg3...]];</span><br></pre></td></tr></table></figure>

<ul>
<li>一般利用公司域名倒置作为包铭；例：com.baidu.www</li>
<li>IDEA创建包会帮忙写好所属的包名：package xxxx;</li>
<li>import xxxx.xxx.xx;使用包</li>
</ul>
<h2 id="快捷键-Alt-回车-（生成错误信息）-然后自动找包-爱了爱了"><a href="#快捷键-Alt-回车-（生成错误信息）-然后自动找包-爱了爱了" class="headerlink" title="快捷键 Alt + 回车 （生成错误信息） 然后自动找包~~爱了爱了~"></a>快捷键 Alt + 回车 （生成错误信息） 然后自动找包~~爱了爱了~</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> base2;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.util.Date;<span class="comment">//这玩意必须在package的下面</span></span><br><span class="line">                        <span class="comment">//import xx.xx.xx就是路径，导入包，也可以导入自己的源码~~</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">class8</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="comment">// x ? y : z</span></span><br><span class="line">        <span class="comment">// 意思为 如果 x==true,则结果为y,否则结果为z</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">score</span> <span class="operator">=</span><span class="number">80</span>;</span><br><span class="line">        <span class="type">String</span> <span class="variable">type</span> <span class="operator">=</span> score &lt;<span class="number">60</span> ? <span class="string">&quot;不及格&quot;</span>:<span class="string">&quot;及格&quot;</span>;</span><br><span class="line">        System.out.println(type);</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="骚操作-import-xx-xx-xx-会将第四个包下的所有类全导入进来捏"><a href="#骚操作-import-xx-xx-xx-会将第四个包下的所有类全导入进来捏" class="headerlink" title="骚操作 import xx.xx.xx.* 会将第四个包下的所有类全导入进来捏"></a>骚操作 import xx.xx.xx.* 会将第四个包下的所有类全导入进来捏</h4><h2 id="Java-Doc"><a href="#Java-Doc" class="headerlink" title="Java Doc"></a>Java Doc</h2><ul>
<li><p>作用：生成自己的API文档</p>
</li>
<li><p>参数信息：</p>
<ul>
<li>@author 作者名</li>
<li>@version 版本号</li>
<li>@since 指明需要最早使用的jdk版本</li>
<li>@param 参数名</li>
<li>@return 返回值情况</li>
<li>@throws 异常抛出情况</li>
</ul>
</li>
<li><p>官方帮助文档得地址捏：docs.oracle.com&#x2F;javase</p>
</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> base2;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span> allure</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@version</span> 1.0</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@since</span> 1.8</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">doc</span> &#123;</span><br><span class="line">    String name;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**   //** +回车就星了</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> name</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">test</span><span class="params">(String name)</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> name;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>关于DIEA右键的翻译</p>
<p>Find Usages             | 搜索用法<br>Analyze 					|分析<br>Refactor					|重新构建<br>——					<br>Bookmarks			   |书签<br>——<br>Browse type Hierarchy|浏览类型层次结构<br>Reformat Code 			 |格式化代码<br>Optimize Imports		  |优化包引用<br>Delete 							 |删除<br>Override File Type		 |覆盖文件类型<br>——<br>Build Module 			     |构建模块<br>——<br>Open in Right Split         |从右边打开<br>Open in							|打开</p>
<p>——<br>Local History					|历史记录<br>Repair IDE						 |修复IDE<br>Reload from Disk			 |从磁盘重新加载<br>——<br>Compare With    			   |与…比较<br>Compart File with Editor  |将文件与编辑器比较<br>——<br>Diagrams							 |图表<br>——<br>Convert java File to Kotlin File|将Java文件转换为Kotlin文件</p>
<h2 id="javadoc的CMD命令"><a href="#javadoc的CMD命令" class="headerlink" title="javadoc的CMD命令"></a>javadoc的CMD命令</h2><p>javadoc -encoding UFT-8 -charset UTF-8 xx.java</p>
<p>​				-编码  参数  -字符 参数  xxx.java</p>
<h2 id="使用IDEA生成javadoc"><a href="#使用IDEA生成javadoc" class="headerlink" title="使用IDEA生成javadoc"></a>使用IDEA生成javadoc</h2><ol>
<li>点击上方的Tool </li>
<li>点击Generate JavaDoc</li>
<li>Out put directory: 则是生成的文档的路径捏</li>
<li>设置各项参数 Loacale:填写zh_CN可以指定以中文格式生成捏</li>
<li>Other command line arguments: 输出配置 就是cmd javadoc 后面写的那些了~~呐呐</li>
</ol>
<h1 id="JAVA流程控制"><a href="#JAVA流程控制" class="headerlink" title="JAVA流程控制"></a>JAVA流程控制</h1><ol>
<li>用户交互Scanner</li>
<li>顺序结构</li>
<li>选择结构</li>
<li>循环结构</li>
<li>Break &amp; continue</li>
<li>练习</li>
</ol>
<ul>
<li><p><strong>Scanner 对象</strong></p>
</li>
<li><p>通过Java给我们提供的工具类，我们可以获取用户的输入。java.util.Sacnner 是Java5的新特征，我们可以通过Scanner类来获取用户的输入。</p>
</li>
<li><p>基本语法：</p>
</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">Scanner</span> <span class="variable">s</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Scanner</span>(System.in);</span><br></pre></td></tr></table></figure>

<ul>
<li>通过Scanner类的next()与nextLine()方法获取输入的字符串，在读取前我们一般需要使用 hasNext()与hasNextLine()判断是否还有输入的数据。</li>
</ul>
<h3 id="next接收"><a href="#next接收" class="headerlink" title="next接收"></a>next接收</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> scanner;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">class1</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="comment">//创建一个扫描器对象，用于接收键盘数据</span></span><br><span class="line">      <span class="type">Scanner</span> <span class="variable">scanner</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Scanner</span>(System.in); <span class="comment">//接收用户的输入 并封装成scanner对象</span></span><br><span class="line">        System.out.println(<span class="string">&quot;使用next方式接收：&quot;</span>);</span><br><span class="line">        <span class="comment">///判断用户有没有输入字符串</span></span><br><span class="line">        <span class="keyword">if</span> (scanner.hasNext()) &#123;<span class="comment">//默认这个里面为判断==true</span></span><br><span class="line">            <span class="comment">//使用next的方式接收</span></span><br><span class="line">            <span class="type">String</span> <span class="variable">str</span> <span class="operator">=</span> scanner.next(); <span class="comment">//程序等待用户输入完毕</span></span><br><span class="line">            System.out.println(<span class="string">&quot;用户输入的内容为&quot;</span> + str);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">//凡是始于IO流的类如果不关闭会一直占用资源，要养成好习惯用完就关掉。</span></span><br><span class="line">        scanner.close();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> scanner;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">calss2</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="type">Scanner</span> <span class="variable">scanner</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Scanner</span>(System.in);</span><br><span class="line">        System.out.println(<span class="string">&quot;使用nextLine方式接收：&quot;</span>);</span><br><span class="line">        <span class="comment">//关闭程序的语句</span></span><br><span class="line">        <span class="keyword">if</span> (scanner.hasNextLine())&#123;<span class="comment">//调用呐呐呐</span></span><br><span class="line">            <span class="type">String</span> <span class="variable">str</span> <span class="operator">=</span> scanner.nextLine();<span class="comment">//等待语句运行</span></span><br><span class="line">            System.out.println(<span class="string">&quot;输出的内容为：&quot;</span>+str);<span class="comment">//输出</span></span><br><span class="line">        &#125;</span><br><span class="line">        scanner.close();<span class="comment">//关闭程序的语句</span></span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


<ul>
<li><p>next()</p>
<ol>
<li>一定要读取到有效字符后才可以结束输出</li>
<li>对输入有效值字符之前遇到的恐怖，next()方法会自动将其去掉。</li>
<li>只有输入有效字符后才将其后面输入的恐怖作为分隔符或者结束符。</li>
<li>next() 不能得到带有空格的字符串。</li>
</ol>
</li>
<li><p>nextLine()</p>
<ol>
<li>以Enter为结束符，也就说nextLine（）方法是返回输入回车之前的所有字符。</li>
<li>可以获得空白。</li>
</ol>
</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> scanner;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">calss3</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="comment">//从键盘接收数据</span></span><br><span class="line">        <span class="type">Scanner</span> <span class="variable">scanner</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Scanner</span>(System.in);</span><br><span class="line">        System.out.println(<span class="string">&quot;请输入数据：&quot;</span>);</span><br><span class="line">        <span class="type">String</span> <span class="variable">str</span> <span class="operator">=</span> scanner.nextLine();</span><br><span class="line">        System.out.println(<span class="string">&quot;输出的内容为:&quot;</span>+str);</span><br><span class="line">        scanner.close();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> scanner;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> javax.security.sasl.SaslClient;</span><br><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">class4</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> &#123;</span><br><span class="line">        <span class="type">Scanner</span> <span class="variable">scanner</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Scanner</span>(System.in);</span><br><span class="line">        <span class="comment">//从键盘接收数据</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">0</span>;</span><br><span class="line">        <span class="type">float</span> <span class="variable">f</span> <span class="operator">=</span> <span class="number">0.0f</span>;</span><br><span class="line">        System.out.println(<span class="string">&quot;请输入整数：&quot;</span>);</span><br><span class="line">        <span class="keyword">if</span> (scanner.hasNextInt())&#123;</span><br><span class="line">           i = scanner.nextInt();</span><br><span class="line">            System.out.println(<span class="string">&quot;整数数据：&quot;</span>+i);&#125;<span class="keyword">else</span> &#123; <span class="comment">//检测i是不是int类型，如果返回为false就走了else，如果不是就继续向下走</span></span><br><span class="line">            System.out.println(<span class="string">&quot;输入的不是整数数据&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        System.out.println(<span class="string">&quot;请输入小数：&quot;</span>);</span><br><span class="line">        <span class="keyword">if</span> (scanner.hasNextFloat())&#123;</span><br><span class="line">            f = scanner.nextFloat();</span><br><span class="line">            System.out.println(<span class="string">&quot;小数数据：&quot;</span>+f);&#125;<span class="keyword">else</span> &#123; <span class="comment">//检测i是不是float类型，如果返回为false就走了else，如果不是就继续向下走</span></span><br><span class="line">            System.out.println(<span class="string">&quot;输入的不是小数数据&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

            <!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->
            <audio id="audio" loop="1" preload="auto" controls="controls" data-autoplay="true">
                <source type="audio/mpeg" src="">
            </audio>
            
                <ul id="audio-list" style="display:none">
                    
                        
                            <li title="0" data-url="http://link.hhtjim.com/163/425570952.mp3"></li>
                        
                    
                        
                            <li title="1" data-url="http://link.hhtjim.com/163/425570952.mp3"></li>
                        
                    
                </ul>
            
        </div>
        
        
    <div id="gitalk-container" class="comment link"
		data-enable="false"
        data-ae="false"
        data-ci=""
        data-cs=""
        data-r=""
        data-o=""
        data-a=""
        data-d="false"
    >查看评论</div>


    </div>
    
</div>


    </div>
</div>
</body>


<script src="//lib.baomitu.com/jquery/1.8.3/jquery.min.js"></script>
<script src="/js/plugin.js"></script>
<script src="/js/typed.js"></script>
<script src="/js/diaspora.js"></script>


<link rel="stylesheet" href="/photoswipe/photoswipe.css">
<link rel="stylesheet" href="/photoswipe/default-skin/default-skin.css">


<script src="/photoswipe/photoswipe.min.js"></script>
<script src="/photoswipe/photoswipe-ui-default.min.js"></script>


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>
    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">
        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>
        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">
            <div class="pswp__top-bar">
                <!--  Controls are self-explanatory. Order can be changed. -->
                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <button class="pswp__button pswp__button--share" title="Share"></button>
                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                      <div class="pswp__preloader__cut">
                        <div class="pswp__preloader__donut"></div>
                      </div>
                    </div>
                </div>
            </div>
            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div> 
            </div>
            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>
            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>
            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>






</html>
